1

00:00:00,360  -->  00:00:06,980
In the previous video, we already learned about
templates in Django. Now in this video,

2

00:00:06,980  -->  00:00:12,980
we are going to learn about context. Context
mean that we can pass data from our

3

00:00:12,980  -->  00:00:16,020
views.py file to templates file.

4

00:00:17,120  -->  00:00:22,560
Okay let’s open
the visual studio code and I will show you what i mean

5

00:00:23,560  -->  00:00:27,740
Go to views.py inside app1 directory

6

00:00:28,420  -->  00:00:34,960
Let me explain about context first. In simple
word, the purpose of context is that we can

7

00:00:34,960  -->  00:00:40,600
access the variable that we have defined in
the views.py from the template file.

8

00:00:41,180  -->  00:00:48,360
Let’s create a context in hello world function,
the type of context must be a dictionary

9

00:00:52,180  -->  00:00:58,260
in this example I create a dictionary about
me, the name will be Ahmad

10

00:01:02,940  -->  00:01:11,660
and let’s say the age is 21. Now we need
to pass this context in the return statement.

11

00:01:13,660  -->  00:01:19,240
When we pass a context in return statement
like this, we can access this data from the

12

00:01:19,240  -->  00:01:28,860
templates, let’s open hello world.html,
here I can access the context data in templates

13

00:01:28,860  -->  00:01:38,520
file using double curly braces like this.
Let’s also put a age context here.

14

00:01:42,680  -->  00:01:55,440
Now let’s open the browser and go to app1/hello_world,
Here we can see that we get Ahmad and 21.

15

00:01:55,620  -->  00:02:02,780
Okay I think this is enough for this video.
Hope you guys understand about context in Django

16

00:02:02,780  -->  00:02:06,020
Thank you for watching and see you
on the next video
